package com.shuzijun.leetcode.editor.cn;

import java.util.ArrayList;

public class CongWeiDaoTouDaYinLianBiaoLcof{
    public static void main(String[] args) {
         Solution solution = new CongWeiDaoTouDaYinLianBiaoLcof().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */
class Solution {
    public int[] reversePrint(ListNode head) {
        if (head == null) return new int[0];

        int[] subResult = reversePrint(head.next);

        int[] result = new int[subResult.length + 1];
        for (int i = 0; i < subResult.length; i++) {
            result[i] = subResult[i];
        }

        result[result.length-1] = head.val;
        return result;
    }





}
//leetcode submit region end(Prohibit modification and deletion)

}